package com.rookie.im.user.controller;


import com.rookie.im.domain.resp.ApiResult;
import com.rookie.im.user.domain.entity.User;
import com.rookie.im.user.req.ImportUserReq;
import com.rookie.im.user.resp.ImportUserResp;
import com.rookie.im.user.service.IUserService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.stereotype.Controller;

import javax.validation.Valid;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author shadaileng
 * @since 2024-05-25
 */
@RestController
@RequestMapping("/user")
@Api(tags = "用户管理")
public class UserController {

    @Autowired
    private IUserService userService;

    @ApiOperation("用户首页")
    @GetMapping("index")
    public String index(){
        User user = userService.getUserById(1);
        return "index: " + user.getUsername();
    }
    @ApiOperation("导入用户")
    @PostMapping("import")
    public ApiResult<ImportUserResp> importUser(@RequestBody @Valid ImportUserReq req){
        ImportUserResp resp = userService.importUser(req);
        return ApiResult.success(resp);
    }
}

